package com.csot.config;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import com.jfinal.plugin.activerecord.Db;

import cn.hutool.core.map.BiMap;

public class Caches {

	private static final BiMap<String, String> fifoDept = new BiMap<>(new ConcurrentHashMap<>());

	public static void initDept() {
		List<com.jfinal.plugin.activerecord.Record> list = Db.find("select dept_id, dept_name from sys_dept");
		for (com.jfinal.plugin.activerecord.Record r : list) {
			fifoDept.put(r.getStr("dept_id"), r.getStr("dept_name"));
		}
	}

	public static String getDeptName(String id) {
		return fifoDept.get(id);
	}

	public static String getDeptId(String name) {
		return fifoDept.getKey(name);
	}

}
